$(function(){
	
	var dateChart = echarts.init(document.getElementById('dateChart'));
	var typeChart = echarts.init(document.getElementById('typeChart'));
	var dateChartTime = [],
		dateChartData = [],
		typeChartTitle = [],
		typeChartData = [];
	
	 $.ajax({
			type:'get',
			url:$Path + '/admin/getMonthFoldLine',
			async:false,
			success:function(data){
				dateChartTime = data.times;
				dateChartData = data.counts;
			}
		});
	 $.ajax({
			type:'get',
			url:$Path + '/admin/getMonthPieChart',
			async:false,
			success:function(data){
				if(data!=null&&data!=undefined){
					if(data.length==0){
						typeChartTitle.push("无");
						typeChartData.push({name:"无",value:1});
					}
					for(var i=0;i<data.length;i++){
						if(data[i].startCourtCount==0){
							continue;
						}
						typeChartTitle.push(data[i].caseType);
						typeChartData.push({name:data[i].caseType,value:data[i].startCourtCount});
					}
				}
			}
		});
	 
	 typeChart.setOption({
			    title : {
			       x:'center',
				   y:'bottom',
				   textAlign:'center',
				   text: "案件种类统计",
				   bottom:'16px',
				   textStyle:{
				     	fontWeight:'normal',
				      	fontSize:18,
				       	color:'#6197cc'
				   }
			    },
			    tooltip : {
			        trigger: 'item',
			        formatter: "{a} <br/>{b} : {c} ({d}%)"
			    },
			    legend: {
			        orient: 'vertical',
			        left: 'left',
			        data: typeChartTitle
			    },
			    series : [
			        {
			            name: '案件类型',
			            type: 'pie',
			            radius : '55%',
			            center: ['50%', '60%'],
			            data:typeChartData,
			            itemStyle: {
			                emphasis: {
			                    shadowBlur: 10,
			                    shadowOffsetX: 0,
			                    shadowColor: 'rgba(0, 0, 0, 0.5)'
			                }
			            }
			        }
			    ]
			});


	dateChart.setOption({
	    title: {
	    	x:'center',
	        y:'bottom',
	        textAlign:'center',
	        text: "最近一月开庭数量统计",
	        bottom:'16px',
	        textStyle:{
	        	fontWeight:'normal',
	        	fontSize:18,
	        	color:'#6197cc'
	        }
	    },
	    tooltip: {
	        trigger: 'axis',
	        formatter: function (params) {
	            params = params[0];
	            return params.name + "开庭" + params.value + '次';
	        },
	        axisPointer: {
	            animation: false
	        }
	    },
	    xAxis : [
	        {
	            type : 'category',
	            boundaryGap : false,
	            axisLine: {onZero: true},
	            data: dateChartTime
	        }
	    ],
	    yAxis : [
	        {
	            type : 'value',
	            boundaryGap: [0, '100%'],
	            splitLine: {
	                show: false
	            }
	        }
	    ],
	    series : [
	        {
	            name:"近一个月内开庭记录",
	            type:'line',
	            symbolSize: 8,
	            hoverAnimation: false,
	            data:dateChartData
	        }
	    ]
	});




})